﻿namespace Leetcode.N1686;
public class Solution
{
    public int StoneGameVI(int[] aliceValues, int[] bobValues)
    {
        var items = new int[aliceValues.Length][];

        for (int i = 0; i < items.Length; i++)
        {
            items[i] = new int[] { aliceValues[i], bobValues[i] };
        }

        items = items.OrderByDescending(i => i.Sum()).ToArray();

        var sums = new int[2];
        for (int i = 0; i < items.Length; i++)
        {
            var valIndex = i % 2;
            sums[valIndex] += items[i][valIndex];
        }

        return sums[0].CompareTo(sums[1]);
    }
}